//
//  HZOAuthModel.m
//  微博 OC
//
//  Created by 黑眼圈 on 16/4/21.
//  Copyright © 2016年 heiyan. All rights reserved.
//

#import "HZOAuthModel.h"

@interface HZOAuthModel()<NSCoding>

@end

@implementation HZOAuthModel


+(instancetype)oauthWithDict:(NSDictionary*)dict{
    
    HZOAuthModel* model = [[HZOAuthModel alloc]init];
    
    //KVC 装换
    [model setValuesForKeysWithDictionary:dict];
    
    return model;
}

//归档
-(void)encodeWithCoder:(NSCoder *)aCoder{
   
    [aCoder encodeObject:self.access_token forKey:@"access_token"];
    [aCoder encodeInteger:self.expires_in forKey:@"expires_in"];
    [aCoder encodeObject:self.remind_in forKey:@"remind_in"];
    [aCoder encodeObject:self.uid forKey:@"uid"];
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeObject:self.profile_image_url forKey:@"profile_image_url"];
}



// 反归档
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
    
   
    if(self = [super init])
    {
      self.access_token = [aDecoder decodeObjectForKey:@"access_token"];
        self.expires_in = [aDecoder decodeIntegerForKey:@"expires_in"];
        self.remind_in = [aDecoder decodeObjectForKey:@"remind_in"];
        self.uid = [aDecoder decodeObjectForKey:@"uid"];
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.profile_image_url = [aDecoder decodeObjectForKey:@"profile_image_url"];
    }
    return self;
    
}

@end
